package org.dk.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.dk.mapper.TbSellerMapper;
import org.dk.pageInfo.PageInfo2;
import org.dk.pojo.TbSeller;
import org.dk.service.SellerService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private TbSellerMapper tbSellerMapper;


    @Override
    public Integer insertSeller(TbSeller tbSeller) {
        int i = tbSellerMapper.insertSelective(tbSeller);
        return i;
    }

    @Override
    public PageInfo2 selectSeller(Integer pageNum, Integer pageSize, String name, String nickName) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbSeller> tl = tbSellerMapper.selectSeller(name,nickName);
        PageInfo pageInfo = new PageInfo(tl);
        PageInfo2<TbSeller> pageInfo1 = new PageInfo2();
        pageInfo1.setPageNum(pageInfo.getPageNum());
        pageInfo1.setPageSize(pageInfo.getSize());
        pageInfo1.setTotal(pageInfo.getTotal());
        pageInfo1.setList(pageInfo.getList());
        pageInfo1.setLastPage(pageInfo.getPages());
        return pageInfo1;
    }

    @Override
    public TbSeller selectById(String sellerId) {
        return tbSellerMapper.selectByPrimaryKey(sellerId);
    }

    @Override
    public void updateSeller(TbSeller seller) {
        tbSellerMapper.updateByPrimaryKeySelective(seller);
    }
}
